import Vue from 'vue'
import Router from 'vue-router'
import config from '../../config/index.js'

Vue.use(Router)
const routeBase = process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath;

const index = resolve => require(['@/views/main/Index.vue'], resolve)
const login = resolve => require(['@/views/login/Index.vue'], resolve)
const register = resolve => require(['@/views/login/Register.vue'], resolve)
const chat = resolve => require(['@/views/chat/Index.vue'], resolve)
const friend = resolve => require(['@/views/friend/Index.vue'], resolve)


const routes = [{
	path: '/',
	redirect: { name: 'login' }
}, {
	path: '/login',
	name: 'login',
	component: login,
}, {
	path: '/register',
	name: 'register',
	component: register,
}, {
	path: '/index',
	name: 'index',
	component: index,
	redirect: { name: 'chat' },
	children: [{
		path: '/chat',
		name: 'chat',
		component: chat
	}, {
		path: '/friend',
		name: 'friend',
		component: friend
	}]
}]

const router = new Router({
	base: routeBase,
	mode: 'history',
	routes: routes
})


export default router
